home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / usenet / st80_pre4 / pretty-print / smalltalkToTexMacro.doc < prev    next >
Text File  |  1993-07-24  |  29KB  |  894 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%%%%%%%%%%%%%%                           %%%%%%%%%%%%%%%%%%%%%%
  3. %%%%%%%%%%%%%%%  smalltalkToTexMacro.doc  %%%%%%%%%%%%%%%%%%%%%%
  4. %%%%%%%%%%%%%%%                           %%%%%%%%%%%%%%%%%%%%%%
  5. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  6.  
  7.  
  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. %%%%%%%%  FAST START  %%%%%%%%%%
  10. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  11.  
  12.  
  13. % If you want to get started really quickly just type:
  14. %    tex example1.tex
  15. %
  16. % alternatively if you have the latex or texinfo formats/macros
  17. % you can type:
  18. %    latex example2.latex
  19. %    tex example3.texinfo
  20. %
  21.  
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. %%%%%%%% INTRODUCTION %%%%%%%%%%
  24. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25.  
  26.  
  27. % SmalltalkToTex can take a standard chunk format file and format
  28. % it VERY NICELY and INFORMATIVELY for printing. You can either
  29. % print a Smalltalk file independently (a source listing) or
  30. % include the Smalltalk code in another TeX document.
  31.  
  32. % These macros will enable you to:
  33. %
  34. %     * print: class name, class hierarchy, version, 
  35. %           print-time, and page numbers in headers and footers.  
  36. %
  37. %     * recognize and format comments, method categories, message
  38. %           selectors and parameters, and special characters
  39. %
  40. %     * do some unusual nice formatting: methods will tend not to
  41. %           break between pages, long lines will wrap indented
  42. %
  43. %     * print your document in multiple ways: one or two column,
  44. %           different section formatting, different headers, etc.
  45. %
  46. %     * communicate information to your main document: for
  47. %           creating an index of message selectors, table of 
  48. %           contents, etc. 
  49.  
  50. %
  51. % As an example of including code in another document, a document  
  52. % using Texinfo from the Free Software Foundation can (trivially) 
  53. % include your smalltalk code and have a table of contents listing
  54. % all your classes and method categories, and have an index of all 
  55. % your message selectors. 
  56. %
  57. % Latex documents have similar functionality (although indexing would
  58. % depend on your local styles).
  59.  
  60.  
  61. % To get access to all the information in your Smalltalk document
  62. % you will have to add `Chunk Comments' that include commands
  63. % to TeX, but these comments will not affect Smalltalk's ability
  64. % to parse your file. The comments are not required, so a standard
  65. % change log can be printed with almost full functionality.  
  66.  
  67.  
  68.  
  69. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  70. %%%%%%%%%% THE FILES %%%%%%%%%%%
  71. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  72.  
  73. %
  74. % To TeX a Smalltalk file using these macros requires three files.
  75. % The first is the Smalltalk file, the second is a Formatting file,
  76. % and the final file is this file itself. 
  77. %
  78. % The Smalltalk and Formatting files handle different functions.
  79. % The Smalltalk file describes the document (the source text itself
  80. % plus possibly other information), and the Formatting file describes
  81. % how you want it printed. You could have multiple Formatting files
  82. % to print the document in different ways, and one of them could
  83. % be another TeX document that wants to import the Smalltalk source
  84. %
  85.  
  86.  
  87. %%%%%%%%%%%%%%%%%%%%%%%%%%
  88. %%%%% SMALLTALK FILE %%%%%
  89. %%%%%%%%%%%%%%%%%%%%%%%%%%
  90.  
  91.  
  92. % The Smalltalk file can be in two different forms:
  93. %   1) A raw chunk format file  -- no changes
  94. %   2) A chunk format file with TeX comments
  95. %
  96. % The choice between the forms will depend on how whether you want to
  97. % modify your Smalltalk environment in trade for more informative 
  98. % (or simply nicer) printing. In terms of changes to Smalltalk:
  99. %
  100. %   Level 1 requires no changes.
  101. %
  102. %   Level 2 requires adding information when filing out a class, 
  103. %   but it can still be read in normally. 
  104. %
  105. %
  106. % In general if you can file out a class at Level 2, 
  107. % you should do so since reading it in should not be a problem. 
  108. % But if you have a file at level 1, you can print that nicely also.
  109.  
  110.  
  111. %%%%%% Printing Groups - FYI %%%%%%%%%%
  112.  
  113. % There are two groups of printing abilities, the basic-information 
  114. % group (the next word is 'and') and the higher-information 
  115. % group. Actually the basic information group includes knowing 
  116. % where comments start, how to wrap long lines, etc. Higher
  117. % information includes the seperation of methods, what the class
  118. % name is, what to index the method selector under, etc. The 
  119. % seperation between the two levels is not very clear (nor very 
  120. % important as it turns out), but it is mostly that no real
  121. % non-text structure is available at the basic-level. 
  122. %
  123. % Samples of how these information groups are used in formatting
  124. % a file are: 
  125.  
  126. % Basic-information related formatting includes:
  127. %   1) Converting characters ( _ = <leftarrow>)
  128. %   2) Wrapping long lines flush right
  129. %   3) Formatting comments, selectors, etc. 
  130. %   4) Two-column mode
  131. %   and a number of other features...
  132. %
  133. % Higher-information related formatting includes:
  134. %   1) Printing information in headers and footers
  135. %   2) Creating Sectioning 
  136. %   3) Calling indexing routines (none are included but
  137. %      you can call Texinfo or LaTeX routines).
  138. %   4) Class seperation (page breaking between classes)
  139. %   5) Avoiding methods being broken between pages
  140. %
  141. %
  142. % Basic information is needed to print the file nicely at all,
  143. % but the higher information is what we really want.
  144. %
  145.  
  146. %%%%%%%%%% Level-1 Formatting %%%%%%%%%%
  147.  
  148. % From a standard smalltalk chunk format file, all the basic 
  149. % information can be determined and a surprising amount of 
  150. % higher level information as well. 
  151. %
  152. % From a standard file these routines can determine:
  153. %   1) Method Category sections
  154. %   2) Method selectors and parameters
  155. %   3) Method seperations
  156. %   4) Print time
  157. %   5) Page Numbers
  158. %
  159. % But it can not determine:
  160. %   1) Where a new class starts 
  161. %                 (although if classes are seperated by file, 
  162. %                  you can just tell it)
  163. %   2) Class name until after a Method Category section
  164. % ------  Stop the presses, the above two can now be managed
  165. % ------  with \findClasses, see the documentation below
  166. % ------
  167. % ------  also note that the class name is found at the first 
  168. % ------  method category section if you use 
  169. % ------  \useProcessingWithNoClasses or a similar command. 
  170. %   3) Superclass hierarchy
  171. %   4) Version
  172. %   5) Category
  173. %   6) Comment sections
  174. % unless given that information in ChunkComments.
  175. %
  176. %
  177. % As an example a standard file containing a single class
  178. % can format the method category sections, selectors, and
  179. % comments (from the basic level). It can also include the 
  180. % category sections in headers, and print in two-column mode.
  181. % Also, if importanted into another document it can add
  182. % section entries to the table of contents and index entries
  183. % for its message selectors
  184. %
  185. %
  186. % but thats quite enough for most of us.
  187.  
  188.  
  189. %%%% Level 2 Formatting: CHUNK COMMENTS %%%%
  190.  
  191. % We really need to be able to give TeX more information, and
  192. % the way I propose to do that would not hurt the Smalltalk file
  193. % at all.
  194. % If some information is added to the Smalltalk file in chunk
  195. % comments (example: "Chunk Comment"!) 
  196. % than the macro can do some nicer formatting. Chunk commands
  197. % must occur as a normal Smalltalk chunk.
  198. %
  199. % The form of a chunk comment for TeX should be:
  200. %   "\TeXCommand
  201. %   ...various commands...
  202. %   "!
  203. %
  204. %      NOTE: the '!' at the end of a chunk comment
  205. %      is neccesary for Smalltalk/V, but may not be
  206. %      for the other versions. These routines don't
  207. %      care either way.
  208. %
  209. % Inside the TeXCommand block are commands that tell TeX other 
  210. % attributes of the Smalltalk file. They do not tell TeX 
  211. % how to format the file, just information that can not
  212. % be read from the file without understanding Smalltalk code.
  213. %
  214. % An example:
  215. %   "\TeXCommand
  216. %   \startClassDef{NewClass}{Object}
  217. %   \setCategory{Testing}
  218. %   \setVersion{2:10 PM on January 1st, 1991}
  219. %   \endClassDef
  220. %   "!
  221. %
  222. % This states that NewClass is a subclass of Object in category
  223. % Testing with version information 2:10 PM ...1991.
  224. % The \startClassDef and \endClassDef must bracket the class
  225. % information (or the information will go on the wrong page).
  226. %
  227. % You could also add your own commands to this environment,
  228. % for example to include diagrams with your output. The environment
  229. % inside a \TeXCommand block is somewhat limited. That you can not
  230. % use double quotes should be the only rule, but a number of 
  231. % other characters are still active. If this is a problem send
  232. % me a bug report. 
  233.  
  234.  
  235.  
  236. %%%% Level 2 continued: SMALLTALK TeXCommands %%%%
  237.  
  238. % The following are the default available TeXCommands:
  239. %
  240. %   \startClassDef{class}{superclass}
  241. %   \setHierarchy{{superclass}{super-superclass}{s^3}{s^4}}
  242. %   \setCategory{category}
  243. %   \setVersion{string}
  244. %   \setClassSection{section}
  245. %   \setClassSubsection{subsection}
  246. %   \endClassDef
  247. %
  248. %   \class{class}{superclass}
  249. %   \startClassSection{section}
  250. %   \startClassSubsection{subsection}
  251. %
  252. %   \setBangDoubled
  253. %   \setBangModal
  254. %   \readFile
  255.  
  256. % \startClassDef{class}{superclass}
  257. %    sets the current class to <class> and the superclass
  258. %    hierarchy to just <superclass>
  259.  
  260. % \setHierarchy{{s1}{s2}{s3}{s4}}
  261. %    sets the superclass hierarchy to an `array' from s1 to s4
  262. %    parameters can be skipped ex: \setHierarchy{{s1}{s2}}
  263.  
  264. % \setCategory{category}
  265. %    set the category 
  266.  
  267. % \setVersion{string}
  268. %    set the version string (generally a date)
  269.  
  270. % \setClassSection{section}
  271. %    set the section for the class (Definition, Class Methods,etc)
  272. %    by default this is set to Definition at the start of
  273. %    defining a class
  274.  
  275. % \setClassSubsection{subsection}
  276. %    set the class subsection {Private, Accessing, etc.).
  277. %    generally used with Methods
  278.  
  279. % \endClassDef
  280. %    end the class definition and print a header
  281.  
  282. % \class{class}{superclass}
  283. %    is a shortHand for:
  284. %    \startClassDef{class}{superclass}\endClassDef
  285.  
  286. %
  287. % \startSection{section}
  288. % \startSubsection{subsection}
  289. %    start a new section/subsection in the middle of a document.
  290. %    Definition, Methods, Class Methods are usually generated
  291. %    automatically, but if you want a Comment section or a 
  292. %    Summary section you can insert them this way...
  293. %
  294.  
  295.  
  296.  
  297. % The next three commands should generally appear only at
  298. % the start of a document, since they would presumably
  299. % stay constant throughout. They could also be put in the 
  300. % Formatting file
  301. %
  302. %
  303. % \setTabs{num}
  304. %    specify a tab character as representing <num> spaces
  305. %    
  306. %
  307. %
  308. % \setBangDoubled
  309. % \setBangModal
  310. %    change how a `!' is interpretted.
  311. %
  312. % Doubled bangs mean `!'s that occur in text (as opposed to the
  313. % formatting bangs) will be doubled. These I replace with a single
  314. % bang when encountered. 
  315. %
  316. % Modal bangs mean bangs in text are not doubled, but must be
  317. % recognized to be non-special when they occur in text or comment
  318. % strings. 
  319. %
  320. % As far as I can tell:
  321. %    Doubled !s are used by Smalltalk-80 and Smalltalk/V
  322. %    Modal !s are apparently used in Gnu-Smalltalk
  323. %      (That's why I added them)
  324. %
  325. % The default is doubled bangs, so you don't need to bother
  326. % mentioning that in the file. In any case this can be handled in 
  327. % the TeX format file if unmentioned.
  328.  
  329.  
  330.  
  331.  
  332. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  333. %%%%%%%% TeX FORMAT FILE %%%%%%%%
  334. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  335.  
  336.  
  337. % The format file is neccesary to read in this macro file
  338. % and then read in the Smalltalk file; at minimum it would
  339. % contain three lines:
  340. %
  341. %   \input smalltalkToTexMacro.tex
  342. %   \startAndRead{smalltalkChunkFile}
  343. %   \end
  344. %
  345. % The format file can also contain other commands between the
  346. % \input and \startAndRead lines. These will effect how
  347. % the file is read and printed. For example:
  348. %
  349. %   \input smalltalkToTexMacro.tex
  350. %      \standardTwoColumnFormat
  351. %      \linenumberstrue
  352. %   \startAndRead{smalltalkChunkFile}
  353. %   \end
  354. %
  355. % will produce a two column format (on a portrait page) and
  356. % show line numbers. A better example would be
  357. %
  358. %   \input smalltalkToTexMacro.tex
  359. %      \standardTwoColumnFormat
  360. %      \setColumnWidth{4.5in}
  361. %      \setGutterSize{0.3in}
  362. %      \setHeight{6.7in}
  363. %   \startAndRead{smalltalkChunkFile}
  364. %   \end
  365. %
  366. % which would change the page to landscape dimensions: 9.3in by 6.7in.
  367. % and skip the line numbering. 
  368. %
  369. % The format file could also be another document (LaTeX or TeX) document
  370. % and the formatting commands would surround the section where you wanted
  371. % to import the smalltalk code. 
  372. %
  373. %
  374.  
  375.  
  376. %%%% FORMATTING COMMANDS %%%%
  377.  
  378. % The following are the default available formatting commands:
  379. %
  380. % \setBangDoubled
  381. % \setBangModal
  382. % \readFile
  383. %
  384. % the above three were documented in the previous sections
  385. %
  386. % \startAndRead
  387. %
  388. % \findClasses
  389. % \dontFindClasses
  390. %
  391. % \formatMethods
  392. % \dontFormatMethods
  393. %
  394. % \useEightPointFonts
  395. % \useTenPointFonts
  396. % \useLatexFonts
  397. % \useTexFonts  
  398. %
  399. % \useCenteredTitles
  400. % \useLeftThirdTitles
  401. % \useLatexTitles
  402. % \useTexinfoTitles
  403. %
  404. % \standardOneColumnFormat
  405. % \standardTwoColumnFormat
  406. % \standardLatexFormat
  407. % \standardTexFormat
  408. % \standardTexinfoFormat
  409. %
  410. % \fromTexDocument
  411. % \fromLatexDocument
  412. % \fromTexinfoDocument
  413. %
  414. % \linenumberstrue
  415. % \linenumbersfalse
  416. %
  417. % \setColumnWidth{width}
  418. %
  419. % \useOneColumnOutput
  420. % \useTwoColumnOutput
  421. %
  422. % \useSimpleFooter    , ...B
  423. % \useOneColumnFooter 
  424. % \useTwoColumnFooter , ...B
  425. %
  426. % \setGutterSize{gutter}
  427. % \setHeight{height}
  428. % \setOffset{xoff}{voff}
  429.  
  430.  
  431. % There could be many additions and revisions to the formatting 
  432. % commands depending on your personal preferences 
  433.  
  434. % \startAndRead
  435. %     not likely to change this. Set up smalltalk verbatim mode
  436. %     and read in the file
  437. %
  438. % \findClasses
  439. % \dontFindClasses
  440. %     \findClasses will turn on attempting to find the start 
  441. %     of a class definition and use the \class command if it 
  442. %     finds it. This should only be used with files that don't
  443. %     have TeXCommands in it (since they already mention the
  444. %     beginning of a class). Also, the very first class in a file 
  445. %     is not found by this routine, so say \class{file}{super} before
  446. %     the \startAndRead for that class.
  447. %
  448. %     \findClasses will fail if a comment (without a ! at the end)
  449. %     precedes the class start. I do not know how much it slows
  450. %     down the program. The default is \dontFindClasses.
  451.  
  452.  
  453. % \formatMethods
  454. % \dontFormatMethods
  455. %     \formatMethods will find the start of method headers and
  456. %     process the selector and parameters. It finishes and calls
  457. %     \doneMethod with token strings set up to be used for
  458. %     formatting, indexing, etc. Generally you would use one 
  459. %     of the default \doneMethod-s, but it is easy to modify
  460. %     them.
  461. %
  462.  
  463.  
  464. % \useEightPointFonts
  465. % \useTenPointFonts
  466. %    set up the fonts for eight and ten point text
  467. %    includes setting the line spacing and skip sizes
  468. %  
  469. % \useLatexFonts
  470. % \useTexFonts  
  471. %    use the current Latex or Tex fonts for TeXing the Smalltalk
  472. %    source. Doesn't affect line spacing, or math fonts
  473. %  
  474. %    \useTexFonts makes all fonts the same size, although
  475. %    different styles, so it is not very useful. If you
  476. %    are calling from a TeX document, preferably use the 
  477. %    point size commands or define your own font
  478. %    format. There is no \useTexinfoFonts since that would
  479. %    make even less sense (at least to me)
  480.  
  481.  
  482. % \useCenteredTitles
  483. % \useLeftThirdTitles
  484. %    set standard formats for the display macros:
  485. %       \classDefined     is called by the \endDefClass command
  486. %       \printTitle       used by the default classDefined
  487. %       \metaMethods      found a !<Class> class methods!
  488. %       \classMethods     found a !<Class> methods!
  489. %       \metaMethodsCat   found a !<Class> class methodsFor: '<cat>'!
  490. %       \classMethodsCat  found a !<Class> methodsFor: '<cat>'!
  491. %       \doneMethod       found and processed a method header 
  492. %
  493. %    left third looks better in twoColumn formats (since Smalltalk
  494. %    lines tend to be short)
  495. %
  496. % \useLatexTitles
  497. %    causes the above formats to call the latex \section (for \printTitle)
  498. %    and \subsection (for \...Methods...) commands. These also
  499. %    call a \setparstuff after the LaTeX commands to fix the paragraphs
  500. %    for the code. If you want different LaTeX calls, just make
  501. %    a new version of this macro, or redefine the displaying macros
  502. %
  503. % \useTexinfoTitles
  504. %    similar to above but for Texinfo.
  505.  
  506. % \useProcessingWithNoClasses
  507. %    alternate processing of \...Methods... that make sense if no
  508. %    class groupings are available. Should be called after one of the
  509. %    above routines. 
  510. %
  511. % \useAlternateDoneMethodA
  512. %    alternate processing of \doneMethod that ignores multiple lines
  513. %    after the message header, and creates index entries for Texinfo.
  514. %    This is mostly as an example of alternate methods.
  515.  
  516.  
  517. % \standardOneColumnFormat
  518. % \standardTwoColumnFormat
  519. % \standardLatexFormat
  520. % \standardTexFormat
  521. % \standardTexinfoFormat
  522. %    sets a number of variables that make sense for printing
  523. %    a useOneColumnOutput, useTwoColumnOutput, or including in a Latex
  524. %    file. Find the macros below to see what they set.
  525.  
  526. %
  527. % \fromTexDocument
  528. % \fromLatexDocument
  529. % \fromTexinfoDocument
  530. %    sets up for importing into another document
  531. %    all automatically call the above \standard equivalent
  532. %
  533.  
  534. % \linenumberstrue
  535. % \linenumbersfalse
  536. %    turns on or off printing line numbers from start of document
  537. %    You could reset the line number at each method by setting
  538. %    \lineno=1 in a modified version of \doneMethod
  539.  
  540. % \setColumnWidth{width}
  541. %    sets each text column on the page to width, if
  542. %    your page is already set up (calling from another
  543. %    document) you should call this routine with your 
  544. %    default value to set the hanging paragraph values
  545. %
  546.  
  547.  
  548.  
  549. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  550. %% The next set of commands are output related and should     %%
  551. %% not be used with LaTeX or inside your own document format, %%
  552. %% unless you understand their macros fully.                  %%
  553. %%                                                            %%
  554. %% Do read the section FOOTERS/HEADERS and examine the footer %%
  555. %% macros to see how to get page information into your        %%
  556. %% documents footers and headers. I haven't tested yet whether%%
  557. %% these work in LaTeX                                        %%
  558. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  559.  
  560. % \useOneColumnOutput
  561. % \useTwoColumnOutput
  562. %    set the output routines two one column or two columns
  563.  
  564.  
  565. % \setGutterSize{gutter}
  566. %    sets the gutter (of a multi-column format)
  567. %
  568. %    the total page size will be:  
  569. %         total = width + ((columns-1) * (gutter + width))
  570. %
  571. % \setHeight{height}
  572. %    the height of the page
  573. %
  574. % \setOffset{xoff}{voff}
  575. %    move the offset of the printed page by:
  576. %       xoff to the right
  577. %       voff downward
  578.  
  579.  
  580. % \useSimpleFooter    , ...B
  581. % \useOneColumnFooter 
  582. % \useTwoColumnFooter , ...B
  583. %    set the footer of the page, useSimpleFooter only uses a page
  584. %    number and a print time, the other two are fancier.
  585. %
  586. %    fancy headers can be defined also, using the same methods
  587. %    as for the footers, but setting \headline instead of \footline
  588. %
  589.  
  590.  
  591. % FOOTERS/HEADERS:
  592. %    To reference values passed by Smalltalk (class, version, etc)
  593. %    in footer or headers you should use \page... commands. 
  594. %    These will produce the right values at the time the 
  595. %    footer/header is printed.
  596. %
  597. %    If a \page... command doesn't exist for what you want (i.e.
  598. %    a different kind of \pageHierarchy) you can create one by looking
  599. %    at the other \page... macros and using \get... macros in
  600. %    your new one. 
  601. %
  602. %    Footers are created when the page is output and look up 
  603. %    information through items called `marks' that were put on
  604. %    the page when it was read in. This becomes moderately 
  605. %    complicated, but is hidden away in the lower level macros.
  606. %
  607.  
  608.  
  609.  
  610.  
  611. %%%%%%%%%%%%%%%%%%%%%%%
  612. %%%%% Other files %%%%%
  613. %%%%%%%%%%%%%%%%%%%%%%%
  614.  
  615. % Although two main files will work for typesetting a Smalltalk
  616. % document, what can work better is to have a log file written
  617. % by Smalltalk listing the files of the most recent filed classes 
  618. % or methods. This file only contains \readFile{filename} 
  619. % commands where the filename-s are for the recently filed-out
  620. % files. If you just filed out:
  621. %     Behavior.st
  622. %     Class.st 
  623. %     MetaClass.st 
  624. %
  625. % a file named fromSmalltalk.tex (for example) would contain:
  626. %    \readFile{Behavior.st}
  627. %    \readFile{Class.st}
  628. %    \readFile{MetaClass.st}
  629. %
  630. % and a format file texSmalltalk.tex would contain at least:
  631. %    \input smalltalkToTexMacro.tex
  632. %    \startAndRead{fromSmalltalk.tex}
  633. %    \end
  634. %
  635. % this would enable you to quickly TeX and print texSmalltalk.tex
  636. % independent of what you just filed out. All the files
  637. % would be formatted together, but the macros reset page numbers
  638. % correctly anyway.
  639. %
  640.  
  641.  
  642. % The command:
  643. %
  644. % \readFile{filename}
  645. %    this reads in another Smalltalk file for typesetting 
  646.  
  647.  
  648. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  649. %%%%%% Using from insidea a LaTeX or TeX document %%%%%%%%%
  650. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  651.  
  652.  
  653.  
  654. % If you are using this macro from another document either
  655. % in TeX, LaTeX, or Texinfo you should be aware of the
  656. % following:
  657.  
  658. % The commands \fromTexDocument, \fromLatexDocument, and
  659. % \fromTexinfoDocument handle most of these aspect for you,
  660. %  but you may want to change the environment.
  661.  
  662. % (Whenever I refer only to LaTeX in this section, I
  663. %  probably meant to refer to importing from any document
  664. %  environment but was lazy when I wrote it).
  665.  
  666. % Don't use the commands that would damage your document
  667. % environment (like resetting the ship-out functions),
  668. % unless you really want it to. In LaTeX these output
  669. % commands should produce errors anyway. These were
  670. % marked as special when mentioned above
  671.  
  672.  
  673. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  674. %%%%%%% Class Ejecting %%%%%%%
  675. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  676.  
  677. % \classEject is called when ever a new class is started,
  678. % but the first time is is called it does nothing, and 
  679. % `loads' its next eject form from \nextClassEject. 
  680. % \classEject should keep this form -- if you want to
  681. % eject the page before starting the Smalltalk code,
  682. % put the eject in your normal code (probably you wouldn't
  683. % think to do otherwise, but it is important)
  684. %
  685. %
  686. % In a normal TeX document, \classEject does what you want
  687. % it to do.
  688. % In a LaTeX document you should redefine \nextClassEject to
  689. % \clearpage or \cleardoublepage or \cleardoublepageLeft
  690. % \cleardoublepageLeft guarantees the following text will
  691. % be on a left hand page (inserting blank pages if neeeded).
  692. % It is defined (far) below if you want to put it with your
  693. % own macros, or need to use it before you have read in this file.
  694. %
  695. %
  696. % \fromLatexDocument defines \nextClassEject as \clearpage
  697.  
  698.  
  699. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  700. %%%%%%%% Mark routines %%%%%%%
  701. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  702.  
  703.  
  704. % These macros communicate to the output routine through 
  705. % \mark-s. This will interfere with LaTeX and possibly
  706. % your own TeX mark routines. This is assumed to be a problem
  707. % and I call \marksOff in the \from... commands. 
  708. %
  709. % If you leave marks off and don't call your marking routines,
  710. % you will simply leave the state of the marks constant.
  711. %
  712. % If you communicate to your mark routines during the smalltalk
  713. % file input, you can use \print... commands to gain access to
  714. % the smalltalk information.
  715. %
  716. %
  717. % If you instead want different output routines during the smalltalk
  718. % section and want to use the \page... commands in them, you can
  719. % turn \marksOn during that period.
  720. %
  721. %
  722. % Turning the \marksOn is not a problem as long as the two mark 
  723. % output environments are kept seperate. This only requires
  724. % ejecting your old page before starting up the smalltalk file
  725. % and ejecting the last smalltalk page before returning to your
  726. % regular text. All the \page... commands will be available during
  727. % the smalltalk pages, and the two types of marks won't interfere.
  728. %
  729. % If you turn \marksOn, you will need to change your output
  730. % routines to use them. If you wrote your own, you know what
  731. % to fix.
  732. % If you are using LaTeX your file will need to do the following:
  733. %
  734. %  eject the page
  735. %
  736. %    1) Save the old LaTeX mark values
  737. %    2) change the output routines to use the desired information
  738. %       from the Smalltalk file
  739. %
  740. %  read in the Smalltalk file
  741. %  eject the last Smalltalk page
  742. %
  743. %    3) Remark with the old values
  744. %    4) Restore the old mark routines
  745. %
  746. %  continue reading your normal file 
  747. %
  748. % The last aspect 4) should be done by putting \begingroup before
  749. % 1) and \endgroup after the eject (before or just after 3). Example
  750. % code that does all this is for LaTeX:
  751. %
  752. %%%
  753. %%% \begingroup
  754. %%% %%% Save the old formatting commands, and set new ones
  755. %%%    \xdef\saveLeft{\leftmark}  %must be global since it will be accessed
  756. %%%    \xdef\saveRight{\rightmark}%outside the group
  757. %%%
  758. %%%    \def\leftmark{\pageClass\ \ddash\ Left}          %or whatever you want
  759. %%%    \def\rightmark{Right\ \ddash\ \pageVersion}      %
  760. %%%
  761. %%%
  762. %%%    \input smalltalkToTexMacro.tex
  763. %%%    \fromLatexDocument
  764. %%%    \marksOn
  765. %%%    %% other commands... 
  766. %%%    \startAndRead{fromSmalltalk.tex}
  767. %%%
  768. %%%    \eject
  769. %%%
  770. %%% %%% Restore the old format
  771. %%%    \markboth{\saveLeft}{\saveRight}
  772. %%%
  773. %%% \endgroup%return \leftmark, \rightmark back to normal
  774. %%%
  775. %
  776.  
  777.  
  778. % ERRORS: If you see a `extra \or' error it is probably from
  779. % not ejecting your page before the smalltalk page. My mark
  780. % routines use a lot of \or-s in them.
  781.  
  782.  
  783. %%%%% Summary for LaTex / other marking routines %%%%%%
  784.  
  785. % To summarize the LaTeX options, you could have:
  786. %   1) \marksOff, and Smalltalk titles (like \useCenteredTitles)
  787. %   2) \marksOff, and LaTeX/Your sectioning
  788. %   3) \marksOn, and Smalltalk titles
  789.  
  790. % For: 
  791. %    1) you don't need to do anything special, but you lose access 
  792. %       to output time access to Smalltalk information
  793. %       
  794. %    2) you also don't need to do anything special, and get access 
  795. %       to the info that was passed to the LaTeX sectioning, and
  796. %       which can include any of the \print... commands
  797. %    
  798. %    3) you need to make sure the mark environments are separated, 
  799. %       make new headers and footers for the style, and then return
  800. %       the environment back when returning to LaTeX. You have access
  801. %       to all the smalltalk values, but can't increment LaTeX sectioning
  802. %       (you do have access to the LaTeX information through \the... 
  803. %       commands.
  804.  
  805. % To get the option use the following commands (assuming LaTeX) 
  806. %    1) \fromLatexDocument
  807. %
  808. %    2) \fromLatexDocument
  809. %       \useLatexTitles
  810. %
  811. %    3) \fromLatexDocument
  812. %       \marksOn
  813. %
  814.  
  815.  
  816. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  817. %%%%%%% Probably Irrelevant LaTeX Option %%%%%%%%%%%
  818. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  819.  
  820.  
  821. % At the moment I don't know why, but you might want to
  822. % have the LaTeX marking command flow throught these 
  823. % macros commands. This would have the LaTeX \section, 
  824. % \subsection... commands calling the smalltalk routines
  825. % and putting extra information into the smalltalk marks.
  826. % Then when LaTeX reads the marks, (via \leftmark \rightmark),
  827. % you would have access to all the information possible.
  828. %
  829. % So to summarize, this option uses LaTeX sectioning and
  830. % output but flows through the smalltalk mark system...
  831. % Documentation for the will be in "latexdoublemark.tex" and
  832. % you should look at the routines called from that document
  833.  
  834.  
  835.  
  836. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  837. %%%%%%% Running TeX %%%%%%%%%%%
  838. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  839.  
  840.  
  841. %
  842. % I will not attempt to describe how to use TeX at your
  843. % site, you hopefully have documentation there. I will
  844. % just make some comments about running TeX with these
  845. % macros.
  846.  
  847. % You should not be surprised if TeX complains about
  848. % `Underfull \hbox'. This is from wrapping long lines.
  849. % I set the tolerance low enough so that TeX tries
  850. % to make the wrapping compact and nice, so if TeX
  851. % can't succeed it complains and tries again. The second
  852. % pass I set the tolerance to infinity, so TeX won't 
  853. % mark you output file in any case. Since the bad
  854. % wrapping is not really bad for our purposes, you 
  855. % can pretty much ignore it. 
  856.  
  857. % Also TeX may complain about `Underfull \vbox' 
  858. % because it did not like any of the breaks it
  859. % found for the current page. This also is not
  860. % really a problem, but it can be remedied 
  861. % by changing the \sectionBreak-s vskip glue
  862. % to allow more stretching and shrinking. This
  863. % also has a benefit of making methods less
  864. % likely to break across a page. 
  865. %
  866. % You could also turn on \raggedbottom to 
  867. % aleviate this problem, if you prefer the
  868. % resulting page breaks. 
  869.  
  870.  
  871. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  872. %%%%%%% Final Documentation %%%%%%%%%%%
  873. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  874.  
  875. % The examples are the best documentation for using
  876. % these macros and the printouts for what they do,
  877. % but if you need to modify them in any way, you will
  878. % have to read the sections below.
  879. %
  880. % I tried order the groups from most likely to modify to least
  881. % likely to modify, but they are grouped by function.
  882.  
  883.